<?php
class comment_model_admincomment extends Model{

	
	public function __construct()
	{
			parent::__construct();
			
	}
	
	//得到所有comment数据
	public function getAllCommentDate($page,$verify, $isdelete)
	{
			$sql	=  "select * from app_com_post where `verify` = $verify  and  `deleted`  = $isdelete  order by create_time desc";
//			echo $sql; exit;
			$params =  array();
			return $this->db->selectPage($sql, $params, $page, 30 );
			
	}	

	
	//通过审核
	public function passVerifyData($s)
	{
		$sql = "update app_com_post set verify = 1  where id  in (" .$s. ") ";
		return $this->db->query($sql);
	}
	
	//删除评论
	public function delVerifyData($s)
	{
		$sql = "update app_com_post set verify = 1 , `deleted` = 2  where  id in (" . $s . ")";
		return $this->db->query($sql);
	}
	
	//恢复评论
	public function recoverdata($id)
	{
		$sql = "update app_com_post set `deleted` = 0  where id  = $id ";
		return $this->db->query($sql);
	}
	
	//搜索
	public function searchCommentDate($page , $uid , $starttime , $endtime)
	{
			$condition = '';
			if ($uid) {
				$condition .= " author_id  = " . $uid . '  and  ';
			}
			if ($starttime && $endtime) {
	
					$condition .= " create_time BETWEEN  " . strtotime($starttime) . " and " . strtotime($endtime) . '  and  ' ;
			} else {
				if($starttime && $endtime == 0){

					$condition .= " create_time BETWEEN  " . strtotime($starttime) . " and " . time() . ' and ' ;
				}
			}
			if ($condition) {
				$sql = " select * from  app_com_post  where   " . $condition . "  `deleted` = 0 " ; 
				return $this->db->selectPage($sql, array(), $page, 30);
			}
	}
	
}